﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="renderer" content="webkit" />
    <title>
        登录页
    </title>
    <meta name="keywords" />
    <meta name="description" />
    <link rel="stylesheet" href="__STATIC__/admin/black_login/css/styles.css" />
</head>

<body>
    <div class="login-bg">
        <div class="login-box">
            <div class="login-tit">{$Think.session.setup.title}</div>
            <ul class="login-list">
                <li class="borb1">
                    <i class="ico-job i-job1"></i>
                    <input id="txt_name" type="text" placeholder="请输入账号" />
                </li>
                <li class="borb1">
                    <i class="ico-job i-job2"></i>
                    <input id="txt_pwd" type="password" placeholder="请输入密码"/>
                </li>
                <li class="borb1 code">
                    <i class="ico-job i-job3"></i>
                    <input id="txt_code" type="text" placeholder="验证码" style="width: 180px"/>
                    <a href="javascript:void(0)" title="看不清，请点击图片刷新" class="verifyCode"
                        style="width: 85px;height: 35px;" onclick="verify()">
                        <img class="verify" width="85" height="35" src="" /></a>
                </li>
                <li class="login-btn">
                    <a href="javascript:;" id="btn_sub" class="btn btn-lg btn-gn">登录 <i class="ico-job i-job6"></i></a>
                </li>
                <li class="login-tips"></li>
            </ul>
        </div>
        <!-- <a href="http://www.64365.com" target="_blank" class="logo-bottom"><img src="picture/logo.png" /></a> -->
    </div>
</body>

</html>
<script type="text/javascript" src="__STATIC__/admin/black_login/js/jquery-1.8.2.min.js"></script>
<script>
    $(function () {
        verify();/*验证码生成*/
        $(document).keydown(function (event) {
            if (event.keyCode == 13) {
                $("#btn_sub").click();
            };
        });
    });
    /*验证码生成*/
    function verify() {
        var url = "{:url('login/verify')}"+"?id="+Math.ceil(Math.random()*100000);
        $(".verify").attr("src",url);
    }
    $('#btn_sub').on('click',
        function () {
            if ($('#txt_name').val().length <= 0) {
                $('.login-tips').text('提示：账号不能为空');
                $('#txt_name').focus();
                return;
            }
            if ($('#txt_pwd').val().length <= 0) {
                $('.login-tips').text('提示：密码不能为空');
                $('#txt_pwd').focus();
                return;
            }
            if ($('#txt_code').val().length <= 0) {
                $('.login-tips').text('提示：验证码不能为空');
                $('#txt_code').focus();
                return;
            }
            if ($('#txt_code').val().length != 4) {
                $('.login-tips').text('提示：请输入正确的验证码位数');
                $('#txt_code').focus();
                return;
            }
            $.ajax({
                type: 'POST',
                url: '{:url("login")}',
                data: {
                    username: $('#txt_name').val(),
                    password: $('#txt_pwd').val(),
                    verifycode: $('#txt_code').val()
                },
                success: function (res) {
                    console.log(res);
                    if (res.code == 1) {
                        $('.login-tips').text(res.message);
                    }
                    if (res.code == 0) {
                        top.location.href = "{:url('admin/index/index')}";
                    }
                },
                dataType: 'json'
            });
        });

</script>